import socket

qq = socket.socket()

qq.connect(('127.0.0.1', 8848))

while 1:
    data = input('>>>(Q q退出)').strip()
    if data.upper() == 'Q':
        qq.send(b'Q')
        break
    qq.send(data.encode('utf-8'))

    from_server = qq.recv(1024)
    print(from_server.decode('utf-8'))

qq.close()